set mem 550m
set matsize 5000
log using "G:\whalley\projects\college_spending\programs\analysis\RESTAT_final\table7.log", replace
#delimit ;
set more 1;
*
* TABLE7.DO
* BY Alex Whalley
* VERSION OF 07/10/09
*
*;
use "G:\whalley\projects\college_spending\programs\analysis\RESTAT_final\main_data.dta", replace;
*
* DROP SMALL COUNTIES
*;
drop if totpop < 250000;
*
* REORMALIZE TOTAL EXPENDITURE
*;
gen ECFET3d1p = ECFET3d1 / 1000; 
drop ECFET3d1;
rename ECFET3d1p ECFET3d1;
gen ECFET3d3p = ECFET3d3 / 1000; 
drop ECFET3d3;
rename ECFET3d3p ECFET3d3;
gen ECFET5d5p = ECFET5d5 / 1000; 
drop ECFET5d5;
rename ECFET5d5p ECFET5d5;
gen endowl4_spindexd3d3_1 = endowl4_spindexd3d3 / 1000;
drop endowl4_spindexd3d3;
rename endowl4_spindexd3d3_1 endowl4_spindexd3d3;
gen endowl6_spindexd5d5_1 = endowl6_spindexd5d5 / 1000;
drop endowl6_spindexd5d5;
rename endowl6_spindexd5d5_1 endowl6_spindexd5d5;
*
* PART (B1): INCOME
*; 
xi: reg ECFET3d3 endowl4_spindexd3d3 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl4_spindexd3d3;
xi: reg lincome3d1 ECFET3d3 i.year [fw=semp81]  if endowl4_spindexd3d3 !=., cluster(FIPSCOUNTY); 
xi: ivreg lincome3d1 (ECFET3d3=endowl4_spindexd3d3 ) i.year [fw=semp81] , cluster(FIPSCOUNTY); 
sum  lincome3d1 if endowl4_spindexd3d3 !=.;
*
* PART (B1): INCOME
*; 
xi: reg ECFET5d5 endowl6_spindexd5d5 i.year [fw=semp81], cluster(FIPSCOUNTY);
test endowl6_spindexd5d5;
xi: reg lincome5d1 ECFET5d5 i.year [fw=semp81]  if endowl6_spindexd5d5 !=., cluster(FIPSCOUNTY); 
xi: ivreg lincome5d1 (ECFET5d5=endowl6_spindexd5d5 ) i.year [fw=semp81] , cluster(FIPSCOUNTY); 
sum  lincome5d1 if endowl6_spindexd5d5 !=.;
*
* CLOSE LOG, CLEAR AND END
*;
log close;
*clear;